/*
 * @lc app=leetcode.cn id=1310 lang=java
 *
 * [1310] 子数组异或查询
 */

// @lc code=start
class Solution {
    public int[] xorQueries(int[] arr, int[][] queries) {
        int len = queries.length;
        int[] ans = new int[len];
        for (int i = 1; i < arr.length; i++) {
            arr[i]^=arr[i-1];//和前面那个做异或运算
        }
        for(int i = 0 ;i<len;i++){
            if(queries[i][0]==0) ans[i]=arr[queries[i][1]];
            else ans[i]=arr[queries[i][0]-1]^arr[queries[i][1]];
        }
        return ans;
    }
}
// @lc code=end

